<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" href="../../assets/css/layui.css">
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>添加快递员</span>
			</div>
			<div class="content">
					<table>
						<tr>
							<td class="text-right">姓名</td><td class="content_right"><input id="realName" class="input" placeholder="请输入姓名"></td>
						</tr>
						<tr>
							<td class="text-right">手机号码</td><td class="content_right"><input id="tel" class="input" placeholder="请输入手机号码"></td>
						</tr>
						<tr>
							<td class="text-right">身份证号码</td><td class="content_right"><input id="identityId" class="input" placeholder="请输入身份证号码"></td>
						</tr>
						<tr>
							<td class="text-right">密码</td><td class="content_right"><input id="password" class="input" placeholder="请输入密码"></td>
						</tr>
						<tr>
							<td></td>
							<td class="content_right">
							<button  type="button"  class="layui-btn layui-btn-blue" id="submit-button" >立即提交</button>
							<button  type="button"  class="layui-btn layui-btn-blue" id="reset-button" >重置</button>
							</td>
						</tr>
					</table>
				
			</div>
		</div>
	</body>
	<script src="../../../js/jquery.min.js"></script>
	<script src="../../assets/layui.all.js"></script>
	<script src="../../../qrcode/jquery2.1.4.js"></script>
	<script src="../../../layer/layer.js"></script>
	<script src="../../../js/request.js"></script>
	<script>
		$(function(){
			$("#reset-button").click(function(){
				$("input").val("");
			});
			$("#tel").focusout(function(){
				var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
				if(!myreg.test($("#tel").val())){
					layer.msg("手机号格式有误,请重新填写")
					$("#tel").val("")
				}
			});
			$("#submit-button").click(function() {
				if($("#realName").val().trim()==="" ||$("#password").val().trim()===""
				||$("#identityId").val().trim()===""||$("#tel").val().trim()===""){
					layer.msg("信息缺失，无法提交")
				} else{
					var windowId = layer.load(2);
					$.post("/courier/insert.do",{
						realName:$("#realName").val(),
						tel:$("#tel").val(),
						identityId:$("#identityId").val(),
						password:$("#password").val(),
					},function(data){
						layer.close(windowId);
						if(data === 'success'){
							layer.msg("用户添加成功");
							$("input").val("");
						}else if(data === 'error') {
							layer.msg("未知异常，用户添加失败");
						}
						else {

							layer.msg(data.result);
						}
					},"JSON");
				}
			});
		});
	</script>
</html>
